# from socket import socket, AF_INET, SOCK_STREAM
#
# s = socket(AF_INET, SOCK_STREAM)
# s.connect(('localhost', 20000))
# s.send(b'Hello World!')
import socket

try:
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect(('localhost', 20000))
    s.send(b'Hello World!')
except ConnectionResetError:
    print("连接被重置，请检查服务器是否运行")
except ConnectionRefusedError:
    print("连接被拒绝，请检查服务器是否启动")
